package com.huobao.yunying.adapters;
import java.util.List;

import com.huobao.yunying.entity.StoreFenlei;
import com.huobao.zhangying.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
public class Adapter_StoreFenlei extends BaseExpandableListAdapter{

	private Context context;
	private LayoutInflater inflater;
	private List<StoreFenlei> fenleis;
	public Adapter_StoreFenlei(Context context,List<StoreFenlei> fenleis){
		this.context = context;
		this.fenleis = fenleis;
		inflater = LayoutInflater.from(context);
	}
	
	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		return fenleis.size();
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		// TODO Auto-generated method stub
		return fenleis.get(groupPosition).children.size();
	}

	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		return fenleis.get(groupPosition);
	}

	@Override
	public Object getChild(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return fenleis.get(groupPosition).children.get(childPosition);
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
		if(convertView == null){
			convertView = inflater.inflate(R.layout.item_store_fenlei, null);
		}
		convertView.setBackgroundResource(R.drawable.selector_listview_1);
		TextView textView = (TextView) convertView.findViewById(R.id.tv_title);
		textView.setText(fenleis.get(groupPosition).item.value);
		return convertView;
	}

	@Override
	public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
			ViewGroup parent) {
		if(convertView == null){
			convertView = inflater.inflate(R.layout.item_store_fenlei, null);
		}
		convertView.setBackgroundResource(R.drawable.selector_listview_2);
		TextView textView = (TextView) convertView.findViewById(R.id.tv_title);
		textView.setText("		"+fenleis.get(groupPosition).children.get(childPosition).value);
		return convertView;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return true;
	}


}
